package com.minivision.sdktestdemo.controler.ui.list;

import android.content.Context;
import android.net.Uri;

import com.minivision.sdktestdemo.bean.KeyBean;
import com.minivision.sdktestdemo.model.AlbumProvider;
import com.minivision.sdktestdemo.model.MusicProvider;

/**
 * Created by devtang on 2016/4/11.
 */
public class AlbumListControler extends ListControler<KeyBean> {

    public AlbumListControler(Context context) {
        mProvider = AlbumProvider.getInstance(MusicProvider.getInstance(context));
    }

    @Override
    public String getTitle(int position) {
        return mProvider.get(position).getmKeyName();
    }

    @Override
    public String getContent(int position) {
        return mProvider.get(position).getmListSongs().size() + "首";
    }

    @Override
    public int getType() {
        return ListControler.ALBUMS;
    }

    @Override
    public Uri getPicUrl(int position) {
        return mProvider.get(position).getmPicUri();
    }

    @Override
    public boolean notifyDataChanged() {
        mProvider.update();
        boolean flag = mProvider.isChanged();
        mProvider.setChanged(false);
        return flag;
    }

    @Override
    public boolean isItemPlayed(String key, int position) {
        return key.equals(getTitle(position));
    }
}
